package Test;

import java.util.ArrayList;
import java.util.Iterator;

public class ArrayList_test {
    public static void main(String[] args) {
        ArrayList<Integer>list=new ArrayList<>();
        list.add(2);
        list.add(41);
        list.add(23);
        list.add(21);
        list.add(56);


        //自增for
        for (int i = 0; i < list.size(); i++) {
            Integer integer =list.get(i);
            System.out.print(integer+"\t");
        }
        System.out.println();
        System.out.println("=================");
        //迭代器
        Iterator<Integer>it= list.iterator();
        while (it.hasNext()) {
            Integer next =  it.next();
            System.out.print(next+"\t");
        }
        System.out.println();
       System.out.println("=================");
       for (Integer integer : list) {
           System.out.print(integer+"\t");
      }

    }
}